package com.ablog.controller;

import com.ablog.model.ArticleType;
import com.ablog.service.ArticleTypeService;
import com.ablog.util.ResultUtil;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (ArticleType)表控制层
 *
 * @author mopeiwen
 * @since 2020-07-22 13:17:40
 */
@RestController
@RequestMapping("/articleType")
public class ArticleTypeController {
    /**
     * 服务对象
     */
    @Resource
    private ArticleTypeService articleTypeService;
    
     /**
     * Select list ResultUtil.
     *
     * @param articleType
     * @return the ResultUtil
     */
    @GetMapping(value = "/query-all")
    public ResultUtil queryAll(ArticleType articleType) {
        return ResultUtil.ok("查询列表", articleTypeService.queryAll(articleType));
    }
    
    /**
     * Select obj ResultUtil.
     *
     * @param id
     * @return the ResultUtil
     */
    @GetMapping(value = "/query")
    public ResultUtil queryById(@RequestParam("id") String id) {
        return ResultUtil.ok("查询详情", articleTypeService.queryById(id));
    }
    
    /**
     * Insert obj ResultUtil.
     *
     * @param articleType
     * @return the ResultUtil
     */
    @PostMapping(value = "/add")
    public ResultUtil add(@RequestBody ArticleType articleType) {
        return ResultUtil.ok("添加成功", articleTypeService.add(articleType));
    }
    
    /**
     * update obj ResultUtil.
     *
     * @param articleType
     * @return the ResultUtil
     */
    @PutMapping(value = "/update")
    public ResultUtil update(@RequestBody ArticleType articleType) {
        return ResultUtil.ok("更新成功", articleTypeService.update(articleType));
    }
    
     /**
     * delete obj ResultUtil.
     *
     * @param id
     * @return the ResultUtil
     */
    @DeleteMapping(value = "/del")
    public ResultUtil delById(@RequestParam("id") String id) {
        return ResultUtil.ok("删除成功", articleTypeService.delById(id));
    }
}